package com.zhuss.team.invest;

import com.zhuss.bean.bo.team.invest.CreateInvestBo;
import com.zhuss.bean.bo.team.invest.DeleteInvestBo;
import com.zhuss.bean.bo.team.invest.InvestQuestionBindBo;
import com.zhuss.bean.bo.team.invest.UpdateInvestBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/26 12:55
 */
@Component("investOperateService")
public class InvestOperateService implements OperateService<Void,Object> {

    @Autowired
    @Qualifier("investCreate")
    private Processor<Object, CreateInvestBo> investCreate;

    @Autowired
    @Qualifier("investUpdate")
    private Processor<Object, UpdateInvestBo> investUpdate;

    @Autowired
    @Qualifier("investDelete")
    private Processor<Object, DeleteInvestBo> investDelete;

    @Autowired
    @Qualifier("investQuestionBind")
    private Processor<Object, InvestQuestionBindBo> investQuestionBind;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void create(Object o) throws WpsException {
        CreateInvestBo bo = (CreateInvestBo) o;
        investCreate.process(bo);
        return null;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object o) throws WpsException {
        UpdateInvestBo bo = (UpdateInvestBo) o;
        investUpdate.process(bo);
        return null;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void delete(Object o) throws WpsException {
        DeleteInvestBo bo = (DeleteInvestBo) o;
        investDelete.process(bo);
        return null;
    }

    /**
     * 给问卷绑定问题
     * @param param
     * @return
     * @throws WpsException
     */
    @Transactional(rollbackFor = Exception.class)
    public Void investQuestionBind(Object param) throws WpsException {
        InvestQuestionBindBo bo = (InvestQuestionBindBo) param;
        investQuestionBind.process(bo);
        return null;
    }
}
